package com.lambkit.module.cms;

import com.jfinal.config.Routes;
import com.lambkit.common.util.StringUtils;
import com.lambkit.module.cms.web.api.controller.AccessApiController;
import com.lambkit.module.cms.web.api.controller.ArticleApiController;
import com.lambkit.module.cms.web.api.controller.CategoryApiController;
import com.lambkit.module.cms.web.api.controller.CommentApiController;
import com.lambkit.module.cms.web.api.controller.FavoriteApiController;
import com.lambkit.module.cms.web.api.controller.KmApiController;
import com.lambkit.module.cms.web.api.controller.MenuApiController;
import com.lambkit.module.cms.web.api.controller.MessageApiController;
import com.lambkit.module.cms.web.api.controller.NoteApiController;
import com.lambkit.module.cms.web.api.controller.PageApiController;
import com.lambkit.module.cms.web.api.controller.RelationApiController;
import com.lambkit.module.cms.web.api.controller.SearchApiController;
import com.lambkit.module.cms.web.api.controller.TagApiController;
import com.lambkit.module.cms.web.api.controller.TopicApiController;
import com.lambkit.module.cms.web.controller.BlogController;
import com.lambkit.module.cms.web.controller.IndexController;
import com.lambkit.module.cms.web.controller.KmController;
import com.lambkit.module.cms.web.controller.NewsController;
import com.lambkit.module.cms.web.controller.PageController;
import com.lambkit.module.cms.web.controller.QaController;
import com.lambkit.module.cms.web.controller.SearchController;
import com.lambkit.module.cms.web.controller.TopicController;
import com.lambkit.module.cms.web.interceptor.CmsWebInterceptor;
import com.lambkit.module.cms.web.user.controller.UserIndexController;

public class CmsWebRoutes extends Routes {

	@Override
	public void config() {
		addInterceptor(new CmsWebInterceptor());
		String url = Cms.config().getUrl();
		url = StringUtils.isBlank(url) ? "/" : url;
		add(url, IndexController.class);
		url = url.endsWith("/") ? url.substring(0, url.length() - 1) : url;
		add(url + "/blog", BlogController.class);
		add(url + "/news", NewsController.class);
		add(url + "/page", PageController.class);
		add(url + "/qa", QaController.class);
		add(url + "/search", SearchController.class);
		add(url + "/topic", TopicController.class);
		add(url + "/km", KmController.class);
		
		add(url + "/user", UserIndexController.class);
		
		//api
		add(url + "/apis/search", SearchApiController.class);
		add(url + "/apis/article", ArticleApiController.class);
		add(url + "/apis/page", PageApiController.class);
		add(url + "/apis/km", KmApiController.class);
		add(url + "/apis/message", MessageApiController.class);
		add(url + "/apis/access", AccessApiController.class);
		add(url + "/apis/category", CategoryApiController.class);
		add(url + "/apis/comment", CommentApiController.class);
		add(url + "/apis/favorite", FavoriteApiController.class);
		add(url + "/apis/menu", MenuApiController.class);
		add(url + "/apis/note", NoteApiController.class);
		add(url + "/apis/relation", RelationApiController.class);
		add(url + "/apis/tag", TagApiController.class);
		add(url + "/apis/topic", TopicApiController.class);
	}
}
